package cn.doitedu.vueapi.flowdata;


import org.apache.commons.codec.binary.Base64;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestLog {

    public static void main(String[] args) throws ParseException {



        String str1 = "120.244.60.182 - - [08/Mar/2020:16:29:03 +0800] \"GET /ewm.html?trace=Njo0 HTTP/1.1\" 200 578 \"-\" \"Mozilla/5.0 (Linux; U; Android 9; zh-cn; MI 8 Build/PKQ1.180729.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/71.0.3578.141 Mobile Safari/537.36 XiaoMi/MiuiBrowser/11.8.14\"";
        String str2 = "120.244.60.182 - - [08/Mar/2020:16:29:03 +0800] \"GET /favicon.ico HTTP/1.1\" 404 548 \"http://www.doitedu.cn/ewm.html?trace=Njo0\" \"Mozilla/5.0 (Linux; U; Android 9; zh-cn; MI 8 Build/PKQ1.180729.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/71.0.3578.141 Mobile Safari/537.36 XiaoMi/MiuiBrowser/11.8.14\"";
        String str3 = "182.254.52.17 - - [08/Mar/2020:16:42:33 +0800] \"GET http://www.doitedu.cn/ewm.html?code%3Dwei34sdkgjk HTTP/1.1\" 200 578 \"-\" \"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:57.0) Gecko/20100101 Firefox/57.0\"";

        String[] strs = new String[]{str1,str2,str3};


        Pattern p2= Pattern.compile("(.*) - - \\[(.*) +.* \"GET /.*trace=(.*) HTTP");
        for(int i=0;i<3;i++) {
            Matcher m = p2.matcher(strs[i]);
            if(m.find()) {
                System.out.println(m.group(1));
                System.out.println(m.group(2));
                System.out.println(m.group(3));
            }else{
                System.out.println("不匹配");
            }
        }


        System.out.println("sbc\n");
        System.out.println("----------");
        System.out.println("sbc\n".trim());
        System.out.println("----------");

    }
}
